﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LevenBlog.Core.Data;

namespace LevenBlog.Data.SqlServer
{
    public sealed class SqlFactory : IFactory
    {
        private static IArchive archive = null;
        private static IBlog blog = null;
        private static ICategory category = null;
        private static IComment comment = null;
        private static IConfig config = null;
        private static IFile file = null;
        private static IImage image = null;
        private static IImageType imagetype = null;
        private static ILog log = null;
        private static IState state = null;
        private static ITag tag = null;
        private static ITrack track = null;
        private static IUser user = null;
        private static IUserInfo userinfo = null;
        private static IUserType usertype = null;
        private static IVisiter visiter = null;
        private static IFriendLink friendlink = null;

        public IDbProvider CreateDbProvider()
        {
            return new SqlProvider();
        }

        public IDbHelper DbHelper
        {
            get { return SqlHelper.Instance; }
        }

        public IArchive Archive
        {
            get
            {
                if (archive == null)
                    archive = new SqlArchive();
                return archive;
            }
        }

        public IBlog Blog
        {
            get
            {
                if (blog == null)
                    blog = new SqlBlog();
                return blog;
            }
        }

        public ICategory Category
        {
            get
            {
                if (category == null)
                    category = new SqlCategory();
                return category;
            }
        }

        public IComment Comment
        {
            get
            {
                if (comment == null)
                    comment = new SqlComment();
                return comment;
            }
        }

        public IConfig Config
        {
            get
            {
                if (config == null)
                    config = new SqlConfig();
                return config;
            }
        }

        public IFile File
        {
            get
            {
                if (file == null)
                    file = new SqlFile();
                return file;
            }
        }

        public IImage Image
        {
            get
            {
                if (image == null)
                    image = new SqlImage();
                return image;
            }
        }

        public IImageType ImageType
        {
            get
            {
                if (imagetype == null)
                    imagetype = new SqlImageType();
                return imagetype;
            }
        }

        public ILog Log
        {
            get
            {
                if (log == null)
                    log = new SqlLog();
                return log;
            }
        }

        public IState State
        {
            get
            {
                if (state == null)
                    state = new SqlState();
                return state;
            }
        }

        public ITag Tag
        {
            get
            {
                if (tag == null)
                    tag = new SqlTag();
                return tag;
            }
        }

        public ITrack Track
        {
            get
            {
                if (track == null)
                    track = new SqlTrack();
                return track;
            }
        }

        public IUser User
        {
            get
            {
                if (user == null)
                    user = new SqlUser();
                return user;
            }
        }

        public IUserInfo UserInfo
        {
            get
            {
                if (userinfo == null)
                    userinfo = new SqlUserInfo();
                return userinfo;
            }
        }

        public IUserType UserType
        {
            get
            {
                if (usertype == null)
                    usertype = new SqlUserType();
                return usertype;
            }
        }

        public IVisiter Visiter
        {
            get
            {
                if (visiter == null)
                    visiter = new SqlVisiter();
                return visiter;
            }
        }

        public IFriendLink FriendLink
        {
            get
            {
                if (friendlink == null)
                    friendlink = new SqlFrindLink();
                return friendlink;
            }
        }
    }
}
